/*
package com.itheima.servlet;

import com.itheima.domian.Studnet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/listservlet")
public class ListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf8");
        String realPath = req.getServletContext().getRealPath("/student.txt");
        System.out.println("realpath"+realPath);
        InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(realPath), "utf-8");
        BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
        String str="";
        List<Studnet>studnets=new ArrayList<>();
        while ((str=bufferedReader.readLine())!=null){
            String[] split = str.split(",");
            studnets.add(new Studnet(split[0],split[1],Integer.parseInt(split[2])));

        }
        bufferedReader.close();
        inputStreamReader.close();

        req.setAttribute("studnets",studnets);
        req.getRequestDispatcher("/WEB-INF/list.jsp").forward(req,resp);


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
*/
